﻿using System.Data.SqlClient;

namespace myWinForm.Temp.TODO
{
    class Customer
    {

        public int AddCustomer(SqlConnection connection, string custommerName, string country, string province, string city, string address, string telephone) {
            SqlCommand command = new SqlCommand("AddCustomer", connection);
            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.Add("@CustomerName", System.Data.SqlDbType.NChar, 50).Value = custommerName;
            command.Parameters.Add("@country", System.Data.SqlDbType.NVarChar, 20).Value = country;
            command.Parameters.Add("@province", System.Data.SqlDbType.NVarChar, 20).Value = province;
            command.Parameters.Add("@city", System.Data.SqlDbType.NVarChar, 20).Value = city;
            command.Parameters.Add("@address", System.Data.SqlDbType.NVarChar, 20).Value = address;

            connection.Open();
            command.ExecuteNonQuery();
            connection.Close();

            int custId = (int)command.Parameters["@CustomerId"].Value;
            return custId;
        }
    }
}
